﻿@{
    Layout = null;
}
@model ElingOA6_Admin_DSJCJ.Model.AlbumCls
<!DOCTYPE html>
<html>
<head>
    <title>相册类别</title>
    @Html.Partial("LoadPanelPartial")
    @if (false)
    {
        <script src="../../../../Scripts/jquery-vsdoc.js" type="text/javascript"></script>
        <script src="../../../../Scripts/ASPxScriptIntelliSense.js" type="text/javascript"></script>
    }
    <link href="@Url.Content("~/Content/Site.css", true)" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/Content/jquery-ui.css", true)" rel="stylesheet" type="text/css" />

    <script src="@Url.Content("~/Scripts/jquery.min.js", true)" type="text/javascript"></script>

    <script src="@Url.Content("~/Scripts/jquery-ui.min.js", true)" type="text/javascript"></script>

    <script src="@Url.Content("~/Scripts/FloatDiv.js", true)" type="text/javascript"></script>

    <script src="@Url.Content("~/Scripts/regex.js", true)" type="text/javascript"></script>

    <script src="@Url.Content("~/Common/GetRootPath.ashx", true)" type="text/javascript"></script>

    <link href="@Url.Content("~/Scripts/dynatree/skin/ui.dynatree.css", true)" rel="stylesheet" type="text/css" />

    <script src="@Url.Content("~/Scripts/dynatree/jquery.dynatree.min.js", true)" type="text/javascript"></script>

    <script src="@Url.Content("~/Scripts/json2.js", true)" type="text/javascript"></script>

    @Html.DevExpress().GetStyleSheets(

    new StyleSheet { ExtensionType = ExtensionType.ListBox, Theme = DevExpressHelper.Theme }
    )
    @Html.DevExpress().GetScripts(
        new Script { ExtensionType = ExtensionType.ListBox }
    )
       <style type="text/css">
        ul.dynatree-container
        {
            overflow:auto;
            position: relative;
        }
      
        
    </style>

    <script type="text/javascript">
        var dataUser = @Html.Raw(Json.Encode(ViewData["treeJsonStrOrgUser"]));
        if (dataUser!="")
            {
                dataUser=JSON.parse(dataUser);
            }
            else
            {
                dataUser=null;
            }
        
    </script>

    <script type="text/javascript">
        $(document).ready(function () {
            $("#toolMenu").smartFloat();
            $("#tabs").tabs();

            $("#orgUserTree").dynatree({
                clickFolderMode: 1,
                selectMode: 3,
                children: dataUser,
                keyboard: false,
                checkbox: true,
                onClick: function (node) {
                },
                onPostInit: function (isReloading, isError) {
                }
            });

            var txtFAlbumClsNo = ASPxClientTextBox.Cast("txtFAlbumClsNo");
            var txtFAlbumClsName = ASPxClientTextBox.Cast("txtFAlbumClsName");
            var hdResult = $("#hdResult").val();
            if (hdResult == "SUCCESS") {
                var hdMethodFromType = $("#hdMethodFromType").val();
                switch (hdMethodFromType) {
                    case "EDIT":
                        {
                            parent.refreshNodeName(txtFAlbumClsName.GetText());
                            break;
                        }

                    case "ADD":
                        {
                            parent.refreshSameLevelNode(txtFAlbumClsName.GetText(), txtFAlbumClsNo.GetText());
                            break;
                        }
                }
            }

            var hdjsAlert = $("#hdjsAlert").val();
            if (hdjsAlert != "") {
                alert(hdjsAlert);
            }
        });
       
        /*保存*/
        function save() {
            if (txtFAlbumClsNo.GetText() == "") {
                alert("相册类别编码不能为空");
                txtFAlbumClsNo.Focus();
                return;
            }
            if (txtFAlbumClsName.GetText() == "") {
                alert("相册类别名称不能为空");
                txtFAlbumClsName.Focus();
                return;
            }

            //用户组成员
            var selNodes = $("#orgUserTree").dynatree("getTree").getSelectedNodes(false);
            var selKeys = $.map(selNodes, function (node) {
                if (node.data.children == null && node.data.addClass == 'user') {
                    return node.data.key;
                }
            });
            $("#hdOrgUserSelect").val(selKeys);

            lpModal.Show();
            form1.submit();

        }
        /*增加*/
        function addGroup() {
            lp.Show();
            window.location.href = rootPath + "/Admin/AlbumClsManage/AddAlbumCls";
        }
        /*删除*/
        function deleteGroup() {
            var txtFAlbumClsNo = ASPxClientTextBox.Cast("txtFAlbumClsNo");
            var txtFAlbumClsName = ASPxClientTextBox.Cast("txtFAlbumClsName");
           
            if (confirm("确定删除【" + txtFAlbumClsName.GetText() + "】吗？")) {
                $.ajax({
                    type: "POST",
                    url: rootPath + "/Admin/AlbumClsManage/DeleteAlbumCls",
                    data: { albumClsNo: txtFAlbumClsNo.GetText() },
                    async: true,
                    success: function (jsonstr) {
                        var msg = jsonstr.split('|');
                        if (msg[0] == "SUCCESS") {
                            alert("删除成功");
                            parent.afterDeleteNode();
                        }
                        else {
                            if (msg.length > 1) {
                                alert(msg[1]);
                            }
                        }
                    }
                });
            }
        }

        function MenuTop_emClick(source, e) {
            switch (e.item.name) {
                case "btnSave":
                    {
                        //保存
                        save();
                        break;
                    }
                case "btnAdd":
                    {
                        //增加同级
                        addGroup();
                        break;
                    }

                case "btnDelete":
                    {
                        //删除
                        deleteGroup();
                        break;
                    }
            }
        }
    </script>

</head>
<body>
    @using (Html.BeginForm("Save", "AlbumClsManage", FormMethod.Post, new { id = "form1", @class = "edit_form" }))
    {
        <div class="floatToolMenu" id="toolMenu" style="z-index: 99;">
            <iframe style="position: absolute; visibility: inherit; top: 0px; left: 0px; width: 100%;
                height: 28px; z-index: -1; background-color: #00CCFF; border-width: 0px; filter='progid:dximagetransform.microsoft.alpha(style=0,opacity=0)';">
            </iframe>
            @Html.DevExpress().Menu(settings =>
       {
           settings.Name = "toolBarMenu";
           settings.ItemAutoWidth = false;
           settings.Width = System.Web.UI.WebControls.Unit.Percentage(100);
           settings.Styles.Style.Border.BorderWidth = System.Web.UI.WebControls.Unit.Pixel(0);
           settings.Styles.Style.BorderTop.BorderWidth = System.Web.UI.WebControls.Unit.Pixel(1);
           settings.Items.Add(item =>
           {
               item.Name = "btnSave";
               item.Text = "保存";
               item.ClientEnabled = true;
               item.Image.Url = Url.Content("~/Content/ControlImages/filesave.png");

           });
           settings.Items.Add(item =>
           {
               item.Name = "btnAdd";
               item.Text = "新增";
               item.ClientEnabled = true;
               item.Image.Url = Url.Content("~/Content/ControlImages/edit_add.png");

           });
           settings.Items.Add(item =>
           {
               item.Name = "btnDelete";
               item.Text = "删除";
               item.ItemStyle.ForeColor = System.Drawing.Color.Red;
               item.ClientEnabled = true;
               item.Image.Url = Url.Content("~/Content/ControlImages/cancel.png");

           });
           settings.ClientSideEvents.ItemClick = "function(source,e){MenuTop_emClick(source,e)}";
           settings.ItemLinkMode = ItemLinkMode.ContentBounds;
       }).GetHtml()
        </div>
        <div>
            <table align="center" class="tableFrom">
                <tr>
                    <th>
                        <font color='red'>*</font>@Html.DevExpress().Label(settings => { settings.Text = "相册类别编码:"; }).GetHtml()
                    </th>
                    <td>
                        @Html.DevExpress().TextBox(settings =>
                   {
                       settings.Name = "txtFAlbumClsNo";
                       settings.Width = 100;
                       settings.Text = Model.FAlbumClsNo;
                       settings.ReadOnly = Model.FAlbumClsNo != null ? true : false;
                   }).GetHtml()
                    </td>
                    <th>
                        <font color='red'>*</font>@Html.DevExpress().Label(settings => { settings.Text = "相册类别名称:"; }).GetHtml()
                    </th>
                    <td>
                        @Html.DevExpress().TextBox(settings =>
                   {
                       settings.Name = "txtFAlbumClsName";
                       settings.Width = 220;
                       settings.Text = Model.FAlbumClsName;
                   }).GetHtml()
                    </td>
                </tr>
            </table>
        </div>
        <div id="tabs" class="div">
            <ul>
                <li><a href="#orgUserTree">发布权限</a></li>
            </ul>
            <div id="orgUserTree">
            </div>
        </div>
        @Html.Hidden("hdalbumClsNo", ViewData["albumClsNo"]);
        @Html.Hidden("hdOrgUserSelect", "");
        @Html.Hidden("hdMethod", ViewData["hdMethod"]);
        @Html.Hidden("hdResult", ViewData["result"]);
        @Html.Hidden("hdjsAlert", (ViewData["jsAlert"]));
        @Html.Hidden("hdFocusKey", ViewData["focusKey"]);
    }
</body>
</html>
